package com.bjxst;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.ObjectInputStream;

public class ObjectInputStreamDemo {
    public static void main(String[] args) {
        ObjectInputStream ois = null;
        try {
            ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream("d:/nn1.txt")));
            //必须按照写入的顺序读取
            System.out.println("int:"+ois.readInt());
            System.out.println("double:"+ois.readDouble());
            System.out.println("char:"+ois.readChar());
            System.out.println("boolean:"+ois.readBoolean());
            System.out.println("String:"+ois.readUTF());
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try{
                if(ois != null) ois.close();
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
